import { TransferReqVO } from '@/api/crm/permission'
import contractApi from '@/api/declaration/crm/contractApi'
import httpRequest from '@/config/axios/httpRequest'
import { CrmContactBusiness2Req, CrmContactBusinessReq, CrmContractInfoModel } from '@/models/crm/CrmContractModel'
// 查询 CRM 联系人列表
export const getContactPage = async (params) => {
  return await httpRequest.get(contractApi.GetContractPage, { params })
}

// 查询 CRM 联系人列表，基于指定客户
export const getContactPageByCustomer = async (params: any) => {
  return await httpRequest.get(contractApi.GetContractPageByCustomer, { params })
}

// 查询 CRM 联系人列表，基于指定商机
export const getContactPageByBusiness = async (params: any) => {
  return await httpRequest.get(contractApi.GetContractPageByBusiness, { params })
}

// 查询 CRM 联系人详情
export const getContact = async (id: number) => {
  return await httpRequest.get(contractApi.GetContract, { params: { id } })
}

// 新增 CRM 联系人
export const createContact = async (data: CrmContractInfoModel) => {
  return await httpRequest.post(contractApi.CreateContract, data)
}

// 修改 CRM 联系人
export const updateContact = async (data: CrmContractInfoModel) => {
  return await httpRequest.put(contractApi.UpdateContract, data)
}

// 删除 CRM 联系人
export const deleteContact = async (id: number) => {
  return await httpRequest.delete(contractApi.DeleteContract, { params: { id } })
}

// 导出 CRM 联系人 Excel
export const exportContact = async (params) => {
  return await httpRequest.download(contractApi.ExportContract, { params })
}

// 获得 CRM 联系人列表（精简）
export const getSimpleContactList = async () => {
  return await httpRequest.get(contractApi.GetContractSimpleList)
}

// 批量新增联系人商机关联
export const createContactBusinessList = async (data: CrmContactBusinessReq) => {
  return await httpRequest.post(contractApi.CreateContractBusinessList, data)
}

// 批量新增联系人商机关联
export const createContactBusinessList2 = async (data: CrmContactBusiness2Req) => {
  return await httpRequest.post(contractApi.CreateContractBusinessList2, data)
}

// 解除联系人商机关联
export const deleteContactBusinessList = async (data: CrmContactBusinessReq) => {
  return await httpRequest.delete(contractApi.DeleteContractBusinessList, { data })
}

// 解除联系人商机关联
export const deleteContactBusinessList2 = async (data: CrmContactBusiness2Req) => {
  return await httpRequest.delete(contractApi.DeleteContractBusinessList2, { data })
}

// 联系人转移
export const transferContact = async (data: TransferReqVO) => {
  return await httpRequest.put(contractApi.TransferContract, data)
}
